//
//  LYQActivityManageInfoCell.m
//  ZCProject
//
//  Created by Zheng on 2016/12/22.
//  Copyright © 2016年 Zheng. All rights reserved.
//

#import "LYQActivityManageInfoCell.h"

@implementation LYQActivityManageInfoCell

- (instancetype)initWithStyle:(LYQActivityManageInfoCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self addSubviewsInContentViewWithStyle:style];
        
        [self layoutSubviewsInContentViewWithStyle:style];
        
    }
    return self;
}

#pragma mark - add subviews
- (void)addSubviewsInContentViewWithStyle:(LYQActivityManageInfoCellStyle)style {
    
    [self.contentView addSubview:self.acImgv];
    [self.contentView addSubview:self.titleLbl];
    
    if (style == LYQActivityManageInfoCellStyleRelease) {
        [self.contentView addSubview:self.readLbl];
        [self.contentView addSubview:self.pNumberLbl];
    } else {
        [self.contentView addSubview:self.sNumberLbl];
        [self.contentView addSubview:self.costLbl];
    }
}

#pragma mark - layout subviews
- (void)layoutSubviewsInContentViewWithStyle:(LYQActivityManageInfoCellStyle)style {
    
    [_acImgv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kWScale(10));
        make.top.mas_equalTo(kWScale(10));
        make.bottom.mas_equalTo(kWScale(-10));
        make.width.equalTo(@(kWScale(110)));
    }];
    
    [_titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_acImgv.mas_right).offset(kWScale(15));
        make.right.mas_equalTo(-kWScale(25));
        make.top.mas_equalTo(kWScale(12));
    }];
    
    if (style == LYQActivityManageInfoCellStyleRelease) {
        
        [_readLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_titleLbl);
            make.bottom.mas_equalTo(-kWScale(12));
        }];
        
        [_pNumberLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-kWScale(15));
            make.bottom.equalTo(_readLbl);
        }];
        
    } else {
        
        [_sNumberLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_titleLbl);
            make.bottom.mas_equalTo(-kWScale(12));
        }];

        [_costLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_sNumberLbl.mas_right).offset(kWScale(20));
            make.bottom.equalTo(_sNumberLbl);
            make.right.mas_equalTo(-kWScale(30));
        }];
        
    }
}

#pragma mark - lazy load subviews
- (UIImageView *)acImgv {
    if (_acImgv) {
        return _acImgv;
    }
    
    _acImgv = [[UIImageView alloc] init];
    _acImgv.backgroundColor = kLYQBlue;
    
    return _acImgv;
}

- (UILabel *)titleLbl {
    if (_titleLbl) {
        return _titleLbl;
    }
    
    _titleLbl = [[UILabel alloc] init];
    _titleLbl.font = kWFont(15);
    _titleLbl.textColor = kLYQBlack;
    _titleLbl.numberOfLines = 2;
    
    return _titleLbl;
}

- (UILabel *)readLbl {
    if (_readLbl) {
        return _readLbl;
    }
    
    _readLbl = [[UILabel alloc] init];
    _readLbl.font = kWFont(14);
    _readLbl.textColor = kHexadecimal(@"666666");
    _readLbl.text = @"阅读 100";
    
    return _readLbl;
}

- (UILabel *)pNumberLbl {
    if (_pNumberLbl) {
        return _pNumberLbl;
    }
    
    _pNumberLbl = [[UILabel alloc] init];
    _pNumberLbl.font = kWFont(14);
    _pNumberLbl.textColor = RGB(252, 107, 74, 1);
    _pNumberLbl.text = @"已报 20";
    
    return _pNumberLbl;
}

- (UILabel *)sNumberLbl {
    if (_sNumberLbl) {
        return _sNumberLbl;
    }
    
    _sNumberLbl = [[UILabel alloc] init];
    _sNumberLbl.font = kWFont(14);
    _sNumberLbl.textColor = RGB(252, 107, 74, 1);
    _sNumberLbl.text = @"200人报名";

    return _sNumberLbl;
}

- (UILabel *)costLbl {
    if (_costLbl) {
        return _costLbl;
    }
    
    _costLbl = [[UILabel alloc] init];
    _costLbl.font = kWFont(14);
    _costLbl.textColor = kHexadecimal(@"666666");
    _costLbl.text = @"免费";
    
    return _costLbl;
}


@end
